//
//  FCSendAndReceiveVC.m
//  FundChain
//
//  Created by 肖浩然的mac on 2018/3/2.
//  Copyright © 2018年 RUIXIN. All rights reserved.
//

#import "FCSendAndReceiveVC.h"
#import "FCWalletSendVC.h"
#import "FCWalletReceiveVC.h"
@interface FCSendAndReceiveVC (){
    UIView     *_viewNav;
}
@property (nonatomic, strong) NSArray *titleData;
/* walletId */
@property (copy, nonatomic) NSString *walletIdStr;
/* 标题 */
@property (strong, nonatomic) UILabel *backLabel;

/* 模型 */
@property (strong, nonatomic) FCBalanceModel *balanceModel;

@end

@implementation FCSendAndReceiveVC

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
  
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    //接收首页的通知
    self.view.backgroundColor = kWhiteColor;
    [self setNav];
    [self setupUI];
    [self setTitle];
    
    
}

-(void)setTitle{
    switch ([self.walletId integerValue]) {
        case 1001:
            {
                self.backLabel.text = Localized(@"比特币");
            }
            break;
        case 1005:
        {
            self.backLabel.text = Localized(@"莱特币");
        }
            break;
        case 1006:
        {
            self.backLabel.text = Localized(@"比特币现金");
        }
            break;
        case 1009:
        {
            self.backLabel.text = Localized(@"加密现金币");
        }
            break;
        case 1010:
        {
            self.backLabel.text = Localized(@"零币");
        }
            break;
            
        default:
            break;
    }
}
#pragma mark 返回子页面的个数
- (NSInteger)numbersOfChildControllersInPageController:(WMPageController *)pageController
{
    return 2;
}
#pragma mark 返回某个index对应的页面
- (UIViewController *)pageController:(WMPageController *)pageController viewControllerAtIndex:(NSInteger)index
{
    switch (index)
    {
        case 0:
        {
            FCWalletSendVC   *vcClass = [[FCWalletSendVC alloc] init];
            vcClass.walletId = self.walletId;
            vcClass.isHomeQRcode = self.isHomeQRcode;
            vcClass.addressStr = self.addressStr;
            vcClass.currentResultModel = self.currentResultModel;
            
            return vcClass;
        }
            break;
        case 1:
        {
            FCWalletReceiveVC *vcClass = [FCWalletReceiveVC new];
             vcClass.walletId = self.walletId;
            vcClass.currentResultModel = self.currentResultModel;
            return vcClass;
        }
            break;
       
        default:
        {
            
        }
            break;
    }
    return nil;
}

#pragma mark 返回index对应的标题
- (NSString *)pageController:(FCSendAndReceiveVC *)pageController titleAtIndex:(NSInteger)index
{
    return self.titleData[index];
}

- (NSArray *)titleData
{
    if (!_titleData) {
        _titleData = @[Localized(@"发送"),Localized(@"接收")];
    }
    return _titleData;
}

#pragma mark-设置UI
-(void)setupUI{
    UIView *topView = [UIView new];
    [self.view addSubview:topView];
    [topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_viewNav.mas_bottom);
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(100*KScreenHeightScale1334);
    }];
    topView.backgroundColor = kRedOrangeColor;
    
}
#pragma mark-自定义导航栏
-(void)setNav{
    self.navigationController.navigationBarHidden = YES;
    _viewNav =[UIView new];
    [self.view addSubview:_viewNav];
    [_viewNav mas_makeConstraints:^(MASConstraintMaker *make) {
        if (@available(iOS 11.0, *)) {
            if (iPhoneX) {
                
                make.left.right.top.mas_equalTo(self.view.safeAreaInsets);
                make.height.mas_equalTo(88);
            }else{
                make.left.right.mas_equalTo(0);
                make.height.mas_equalTo(64);
                make.top.mas_equalTo(0);
            }
        }else{
            make.left.right.mas_equalTo(0);
            make.height.mas_equalTo(64);
            make.top.mas_equalTo(0);
        }
        
    }];
    _viewNav.backgroundColor = kRedOrangeColor;
    
    UIButton *leftBtn = [UIButton new];
    [self.view addSubview:leftBtn];
    [leftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15*KScreenWidthScale750);
        make.centerY.mas_equalTo(_viewNav.mas_centerY).offset(8);
        make.size.mas_equalTo(CGSizeMake(40, 40));
    }];
    [leftBtn setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal];

    [leftBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    //返回
    UILabel *backLabel = [UILabel new];
    self.backLabel = backLabel;
    [_viewNav addSubview:backLabel];
    [backLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(_viewNav);
        make.centerY.mas_equalTo(_viewNav.mas_centerY).offset(8);
    }];
    backLabel.text = Localized(@"比特币钱包");
    backLabel.textColor = [UIColor whiteColor];
    backLabel.font = KOverstrikingfont(36);
    //事件
    [leftBtn addTarget:self action:@selector(leftBtnClick) forControlEvents:UIControlEventTouchUpInside];
    
}

-(void)leftBtnClick{
    if (self.isHomeQRcode) {
        [self.navigationController popToRootViewControllerAnimated:NO];
    }else{
    
    [self.navigationController popViewControllerAnimated:YES];
    }
}
//自定义
- (UIView *)menuView:(WMMenuView *)menu badgeViewAtIndex:(NSInteger)index {
    
    switch (index) {
        case 1: case 0:{
            
            
            UIImageView * imageView = [UIImageView new];
            imageView.frame = CGRectMake(0, 164, 20, 20);
            imageView.userInteractionEnabled = false;
            return imageView;
        }
            break;
        default:
            return nil;
            break;
    }
}
#pragma mark 初始化代码
- (instancetype)init
{
    if (self = [super init])
    {
        
        self.titleSizeNormal = 20;
        self.titleSizeSelected = 20;
        self.titleColorSelected = kWhiteColor;
        self.titleColorNormal = HEXACOLOR(0xffffff, 0.3);
        self.progressHeight = 3;
        self.itemMargin = 20;
        self.progressColor = kWhiteColor;
        self.menuViewStyle = WMMenuViewStyleLine;
        self.menuItemWidth = SCREEN_WIDTH / (5);
        self.pageAnimatable = false;
        if (iPhone6p) {
            self.menuItemWidth = SCREEN_WIDTH / (6);
        }else if(SCREEN_WIDTH == 320){
          self.menuItemWidth = SCREEN_WIDTH / (4);
        }
        self.menuHeight = 30;
        self.startDragging = YES;
        self.menuBGColor = kRedOrangeColor;
        self.menuViewLayoutMode = WMMenuViewLayoutModeLeft;
        self.otherGestureRecognizerSimultaneously = NO;
        if (iPhone6p) {
            self.viewFrame = CGRectMake(0, 208*KScreenHeightScale1334, SCREEN_WIDTH, SCREEN_HEIGHT);
        }else if (SCREEN_WIDTH == 320){
            self.viewFrame = CGRectMake(0, 238*KScreenHeightScale1334, SCREEN_WIDTH, SCREEN_HEIGHT);
            
        }else{
        self.viewFrame = CGRectMake(0, 228*KScreenHeightScale1334, SCREEN_WIDTH, SCREEN_HEIGHT);
        }
    }
    return self;
}

@end
